package com.virtualtrainer_01.view;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.OnChildClickListener;
import android.widget.Toast;

import com.virtualtrainer_01.R;
import com.virtualtrainer_01.viewListeners.ExpandableListAdapter;

public class Informations extends Activity {

	private ExpandableListView exp;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.informations);
		getActionBar().setDisplayHomeAsUpEnabled(true);
		
		exp = (ExpandableListView) findViewById(R.id.expandableListView2);
		exp.setAdapter(new ExpandableListAdapter(this));
		exp.setOnChildClickListener(new OnChildClickListener() {

			@Override
			public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
				try {
					String exName = ((ExpandableListAdapter) exp.getExpandableListAdapter()).getChildList()[groupPosition][childPosition];				
					Intent intent = new Intent(Informations.this, Description.class);
					intent.putExtra("cheia", exName);
					startActivityForResult(intent, 1);
				} catch (Exception ex) {
					ex.printStackTrace();
					Toast.makeText(Informations.this, "Error", Toast.LENGTH_LONG).show();
				}return false;
			}
		});
	}
}